import 'package:flutter_shop_z/model/category_sub.dart';

//一级类别类
class CategoryBean {
  int categoryId; //一级类别ID
  String categoryName; //一级类别名称
  String categoryDescribe; //一级类别描述
  String categoryImg; //一级类别图片
  List categorySubList; //二级分类

  //构造器
  CategoryBean(
      {this.categoryId,
      this.categoryName,
      this.categoryDescribe,
      this.categoryImg,
      this.categorySubList});

  //工厂模式-使用这个模式可以省略New关键字
  factory CategoryBean.fromJson(dynamic json) {
    return CategoryBean(
        categoryId: json['categoryId'],
        categoryName: json['categoryName'],
        categoryDescribe: json['categoryDescribe'],
        categoryImg: json['categoryImg'],
        categorySubList: json['categorySubList']);
  }
}

class CategoryListBean {
  List<CategoryBean> data;
  CategoryListBean(this.data);
  factory CategoryListBean.formJson(List json) {
    return CategoryListBean(json.map((i) => CategoryBean.fromJson(i)).toList());
  }
}
